Component({
  properties: {
    placeholder: {
      type: String,
      value: '以 "/" 开头启用 AI 智搜',
    },
    value: {
      type: String,
      value: "",
    },
  },

  data: {
    inputValue: "",
  },

  lifetimes: {
    attached() {
      this.setData({
        inputValue: this.properties.value,
      })
    },
  },

  methods: {
    onInput(event) {
      const value = event.detail
      this.setData({
        inputValue: value,
      })
      this.triggerEvent("input", value)
    },

    onSearch() {
      // console.log("组件内 onSearch 触发:", this.data.inputValue)
      this.triggerEvent("search", this.data.inputValue)
    },
    

    onCancel() {
      this.setData({
        inputValue: "",
      })
      this.triggerEvent("cancel")
    },
  },
})
